<?php					
include_once('functions/discogs.php');
if(!isset($_GET['search'])) {
	$_GET['search'] = 'null';	
}
if(isset($_GET['artist'])) {
$result = $discogs->artist($_GET['artist']);
//Retrieves artist image, memberlist, profile using discogs API
echo'<header class="newsheader">';
echo $_GET['artist'];
echo '</header><section class="newssection">';
	if(!empty($result->images[0]->uri150)){
		echo '<img src="' . $result->images[0]->uri150 . '"/>';
	}
	
	if (!empty($result->members)) {
		echo '<h3>Members:</h3>';	
		foreach ($result->members as &$value) {
			echo $value;
			echo '<br>';
		}	
	}

	if (!empty($result->profile)) {	
		echo '<h3>Brief information:</h3>';	
		echo $result->profile;
	}
	//Retrieves listen count for the artist.
	try {
		echo '<br><br>'.$result->name.' has been listened to '.artistListenCount(str_replace(' ', '+', $result->name)).' times via MyMS.';
	} catch (Exception $e) {
		echo '<br><br>'.$result->name.' has been listened to 0 times via MyMS.';
	}
}
echo'</section>
<footer class="newsfooter"></footer>';

?>
